package cn.agiledata.bank.transaction.service;

import cn.agiledata.bank.hibernateBean.ActionType;
import cn.agiledata.bank.hibernateBean.ModelType;
import cn.agiledata.bank.hibernateBean.Transaction;
import cn.agiledata.bank.common.dao.ActionTypeTemplate;
import cn.agiledata.bank.common.util.Constant;
import com.vnv.infrastructure.exception.IPBException;
import com.vnv.infrastructure.logic.IPBMgrFactory;

public class ActionTypeAndModelTypeMatch {

	protected static ModelType getModelType(Transaction tran){
		 ActionTypeTemplate att = null;

			att = (ActionTypeTemplate)
			IPBMgrFactory.getMgr("actionTypeTemplate");
	
		
		
		ModelType mt = new ModelType();
		if (tran.getOperate()==null){
			//如果actiontype是账户付款给对方银行，则moduletype为提现
			if (tran.getActionType().getId().toString().
					equals(Constant.ACTION_TYPE_G)||
					tran.getActionType().getId().toString().
					equals(Constant.ACTION_TYPE_H)){
				mt = att.getModelType(Constant.MODEL_TYPE_GAINMONEY);
			}else{
				mt = att.getModelType(tran.getActionType().getId().toString());
			}
		}else{
			mt = att.getModelType(tran.getOperate());
		}

		if (tran.getPrimaryModuleType() != null){
			mt = att.getModelType(tran.getPrimaryModuleType());
		}
		return mt;
	}
}
